Allow overriding /ko-app folder on Linux#1704
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
Reviewed by Cursor Bugbot for commit b163e5e. Configure here.
| default: | ||
| appDir = "/ko-app" | ||
| appPath = path.Join(appDir, appFileName) | ||
| } |
There was a problem hiding this comment.
Windows ignores binary path override
High Severity · Logic Bug
When binaryFolder or binaryPath are used, the binary's location within Windows images is customized. However, the Windows entrypoint and PATH environment variable still expect the binary at C:\ko-app. This mismatch causes Windows images to fail to start.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b163e5e. Configure here.
| default: | ||
| appDir = "/ko-app" | ||
| appPath = path.Join(appDir, appFileName) | ||
| } |
There was a problem hiding this comment.
Cache omits destination path
High Severity · Logic Bug
When KOCACHE is enabled, the binary layer cache key doesn't include the binary's in-image path, which can now be overridden by binaryFolder or binaryPath. If only the in-image path changes, the cache may return a hit, but the layer's tarball content will be rebuilt with the new path, leading to a digest/blob mismatch.
Reviewed by Cursor Bugbot for commit b163e5e. Configure here.


Allow overriding the binary folder
/ko-appwith something else.Can be useful in some scenarios, e.g, in a Kubernetes environment where a fixed command/path is expected and you can only change the image.
(Only for Linux, I'm not familiar with how Windows containers work or what impact the change might have on them)
Closes #944
Note
Medium Risk
Changes image entrypoint and filesystem layout for every Linux build when overrides are used; default
/ko-appis unchanged and behavior is covered by tests, but wrong paths could break deployments that expect a fixed command.Overview
Adds
binaryFolderandbinaryPathso Linux images can place the compiled binary somewhere other than/ko-app/<app-name>, while keeping the default when unset.binaryFolderonly changes the directory (app name still derived from the import path);binaryPathsets the full absolute path and wins if both are set (with a log when both are configured). These map through.ko.yaml/KO_BINARYFOLDERandKO_BINARYPATH,BuildOptions, andWithBinaryFolder/WithBinaryPathinto the go build path that sets the image entrypoint and binary layer.On Linux,
tarBinarynow creates parent directories viaparentDirsfor arbitrary override paths instead of hard-codingko-app; Windows layering still usesFiles/ko-app. Docs and tests cover defaults, overrides, precedence, and tar directory headers.Reviewed by Cursor Bugbot for commit b163e5e. Bugbot is set up for automated code reviews on this repo. Configure here.